#ifndef VIDEOWINDOW_H
#define VIDEOWINDOW_H
/***
 * author: JianYu
 * time: 2025.6.27
 * func: 单个播放窗口管理，包括videoreceive和videoplayer的调用，供mainwindow调用
 */
#include <QMainWindow>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QGroupBox>
#include <QMessageBox>
#include <QDateTime>
#include <QGuiApplication>
#include <QScreen>
#include <QAction>
#include <QMenu>

#include "videoreceiver.h"
#include "videoplayer.h"
#include  "common.h"

class VideoWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit VideoWindow(QString cameraName, QString intf, QString ip, quint16 listenPort,
                         int bindWay, QWidget *parent = nullptr);

    void startReceiving();  //开始监听端口

    void resetSettings(QString ip, quint16 listenPort, QString infName, int bindWay);

private:
    QString m_cameraName;   //相机名称
    quint16 m_listenPort;   //监听端口
    QString m_intf;         //组播绑定的网卡名称
    QString m_ip;           //网卡ip
    int m_bindWay;          //udp接收绑定方法 单播：1 组播： 2 广播: 3

    VideoReceiver *m_receive; //视频接收和解码类
    VideoPlayer *m_player; //视频显示界面

    QGroupBox *receiverGroupBox;
    QVBoxLayout *receiverLayout;
    QLabel *m_videoLabels;  //视频显示控件

signals:
    void sigSendDataToSave(const QByteArray &data, QString ipSrc, quint16 portSrc);  //转发后存储
    void sigSrcIP(QString);  //发送ip源到设置界面
    void sigVideoInfoChanged(int width, int height, int fps);

public slots:
    void onFrameReceived(const QImage &image);  //接收图片并显示
};

#endif // VIDEOWINDOW_H
